Inheritance

  • Note

    What is Inheritance

    Inheritance is a feature of OOPS. It allows a child class to reuse and extend the properties and functionality of a parent class.

    Why Use Inheritance?

    Code Reusability: (avoid duplication)

    multiple subclasses can reuse the common functionalities implemented in parent class. So reducing redundancy (duplication).

    Extensibility

    New functionality can be added to a subclass without modifying the code of the parent class.

    Easier maintenance

    Changes made in the superclass automatically apply to all its subclasses (derived class / child class)

    How does implement the code

    using the keyword "extends"

    types of inheritance